#pragma once
#include "../core/cpputil.h"
#include <vector>
class CTreeCtrlItem;

class TreeItemImpl
{
public:
	virtual ~TreeItemImpl(){}
	virtual void OnClick(const CTreeCtrlItem& ctrlItem){}
	virtual void OnDblClick(const CTreeCtrlItem& ctrlItem){} //left button double click
	virtual void OnRClick(const CTreeCtrlItem& ctrlItem){}
};





class CGTDTreeCtrl : public CTreeCtrl
{
public:
	void SetItemImpl(HTREEITEM item, TreeItemImpl*pImpl);
	TreeItemImpl* GetItemImpl(HTREEITEM item)const;


	void Init();
	
	void SetNormalImageList(int resID)
	{		
		m_imgList.DeleteImageList();
		m_imgList.Create(resID,16, 1, RGB(255,255,255));
		SetImageList(&m_imgList,TVSIL_NORMAL);
	}
	void SetStateImageList(int resID)
	{
		m_imgStateList.DeleteImageList();
		m_imgStateList.Create(resID,13,1, RGB(255,255,255));
		SetImageList(&m_imgStateList,TVSIL_STATE);
	}

	DECLARE_DYNAMIC(CGTDTreeCtrl)
	DECLARE_MESSAGE_MAP()



protected:
	//{{AFX_MSG(CCoolTree)
	afx_msg void OnClick(NMHDR* pNMHDR, LRESULT* pResult);
	//afx_msg void OnDblclk(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);	
	afx_msg void OnRclick(NMHDR* pNMHDR, LRESULT* pResult);	
	//afx_msg BOOL OnEraseBkgnd(CDC* pDC);

	afx_msg void OnTvnItemexpanding(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnTvnSelchanged(NMHDR *pNMHDR, LRESULT *pResult);
	//afx_msg void OnTvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	//afx_msg void OnTvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult);
	//afx_msg void OnPaint();


protected:
	typedef cpputil::DataPool<TreeItemImpl> TreeItemImplPool;
	TreeItemImplPool m_vItemImpls;	
	
	CImageList m_imgList;
	CImageList m_imgStateList;
};

